package com.msmall.community.common.action.wml;

import java.util.Date;

import com.msmall.base.action.WMLBaseAction;
import com.msmall.base.util.ConstantDB;
import com.msmall.base.util.Constants;
import com.msmall.community.common.model.Abuse;
import com.msmall.community.common.service.AbuseManager;


public class AbuseAction extends WMLBaseAction{

	private static final long serialVersionUID = -3072466258343437297L;

	private Long entityId;
	
	private Short abuseType;
	
	private String toUrl;
	
	private Abuse abuse;
	
	private AbuseManager abuseManager;
	
	public String report(){
		abuse = new Abuse();
		String url = "";
		if(abuseType.compareTo((short)1) == 0){ // 举报帖子
			url = topicReportUrl();
		}
		if(abuseType.compareTo((short)2) == 0){ // 举报回复
			url = threadReportUrl();
		}
		if(abuseType.compareTo((short)3) == 0){ //举报博客文章
			url = blogReportUrl();
		}
		setToUrl(url);
		abuse  = new Abuse();
		abuse.setAbuseType(abuseType);
		abuse.setAudit(ConstantDB.AUDIT_NONE);
		abuse.setEntity(entityId);
		abuse.setReporter(getUserid());
		abuse.setReportTime(new Date());
		abuse.setUrl(url);
		abuseManager.report(abuse);
		return SUCCESS;
	}

	private String topicReportUrl(){
		String url = "bbsx/viewTopic.do?topicId=" + entityId;
		
		return url;
	}
	private String blogReportUrl(){
		return "";
	}
	private String threadReportUrl(){
		return "";
	}
	public Long getEntityId() {
		return entityId;
	}

	public void setEntityId(Long entityId) {
		this.entityId = entityId;
	}

	public Short getAbuseType() {
		return abuseType;
	}

	public void setAbuseType(Short abuseType) {
		this.abuseType = abuseType;
	}

	public String getToUrl() {
		return toUrl;
	}

	public void setToUrl(String toUrl) {
		this.toUrl = toUrl;
	}

	public Abuse getAbuse() {
		return abuse;
	}

	public void setAbuse(Abuse abuse) {
		this.abuse = abuse;
	}

	public void setAbuseManager(AbuseManager abuseManager) {
		this.abuseManager = abuseManager;
	}
}
